package com.mec.fileTransfer.core;

import java.util.ArrayList;
import java.util.List;

public class TestSender2 {

	public static void main(String[] args) {
		String absolutePath = "F:\\testFileTransferSender\\";
		try {
			String filePath;
			int length;
			ReceiveFileSet fileSet = new ReceiveFileSet();
			ReceiveFileModel file;
			List<SendFileModel> fileList = new ArrayList<>();
			

			filePath = "video\\tianfu.mp4";
			//526084217 500000000
			length = 500000000;
			file = new ReceiveFileModel(
					filePath, length, absolutePath);
			fileSet.addFile(1, file);
			
			long off = 526084217;
			while (length > 0) {
				int len = length > ResourceSender.BUFFER_SIZE
						? ResourceSender.BUFFER_SIZE : length;
				SendFileModel sendFile = new SendFileModel()
						.setAbsoluteRootPath(absolutePath)
						.setFilePath(filePath)
						.setOffset(off)
						.setLength(len);
				fileList.add(sendFile);
				length -= len;
				off += len;
			}

			//产生发送中心对象，并进行启动
			ResourceSenderCenter senderCenter = new ResourceSenderCenter(
					"192.168.137.1", 54189);
			senderCenter.setSendFileSet(fileSet);
			senderCenter.setSendFileList(fileList);
			senderCenter.startSendding();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
